export enum MenuId {
  DOWNLOAD = 'download',
  PARSE_LIST = 'parse_list',
  OPTIONS = 'options'
}

export enum EventType {
  CONNECT = 'connect',
  /** contextMenu 的值 */
  CONTEXT_MENU = 'contextmenu',
  /** 视频列表的解析结果 */
  VIDEO_LIST = 'videolist'
}

export interface MessageEvent {
  /** 当前程序的内部验证字段 */
  messageId?: string
  /** 传递的数据 */
  data?: any
}

/**
 * 右击菜单栏事件
 */
export interface ContentMenuMessageEvent extends MessageEvent {
  /** 事件类型 */
  type: EventType.CONTEXT_MENU
  /** 菜单栏的标识 */
  data: MenuId
}

/**
 * 建立通信连接的请求事件
 */
export interface ConnectMessageEvent extends MessageEvent {
  /** 事件类型 */
  type: EventType.CONNECT
}

export type PostMessageEvent = ContentMenuMessageEvent | ConnectMessageEvent

export const origin = 'https://developer.chrome.com'

export const messageId = 'Y2hyb21lIGV4dGVuc2lvbiB2aWRlbyBkb3dubG9hZA=='
